/**
 * Created by Administrator on 2016/4/19.
 */
/**
 * Created by Administrator on 2016/4/11.
 */
var yanzhengma=$("#yanzhengma").val();

/*   var b =$("#pwd").attr("value");*/
var countdown=60;

function settime(val) {

    if (countdown == 0) {
        val.removeAttribute("disabled");
        val.value="点击获取验证码";
        countdown = 60;
        return;

    } else {
        val.setAttribute("disabled", true);
        val.value="重新发送(" + countdown + ")";
        countdown--;
    }
    setTimeout(function() {
        settime(val)
    },1000)

}

$(function(){
    $("#yzm").click(function(){
        var a =$("#pwd").val();
        $.ajax({
            url: "hxclub/member/pwd/sendSMS.do",
            async: false,
            type: "post",
            dataType: "json",
            data: {"mphone": "" + a + ""/*, "codes": "" + codes + ""*/},

            success: function (data) {
                if (data.success == false) {
                    alert("验证码发送失败")
                } else {
                    alert("验证码发送成功")
                }
            }
        });

    });


    $("#next").click(function(){
        var a =$("#pwd").val();


        var yanzhengma=$("#yanzhengma").val();
        if(a.length<1 || a=="手机号"){
            alert("手机号不能为空")
            return false;
        }
        if(yanzhengma.length<1 || yanzhengma=="验证码"){
            alert("验证码不能为空")
            return false;
        }else{
            $.ajax({
                url: "hxclub/member/pwd/checkSMScode.do",
                async: false,
                type: "post",
                dataType: "json",
                data: { "mphone": "" + a + "", "smsCode": "" + yanzhengma + ""},

                success: function (data) {
                    var id=data.data
                    if (data.success == false) {
                        alert("验证码错误")
                    } else {
                        alert("验证码正确")
                        window.location.href = "../updatepwd.html?id="+id;

                    }
                }
            });

        }
    }).mousedown(function(){
        $("#next").addClass("l_anniu")
    }).mouseout(function(){
        $("#next").removeClass("l_anniu")
    });


})